﻿
namespace Sidvall.WorkItemManager.Model.DataPortalManagers
{
    public partial class WorkItemTypeManager<TEntity, TList>
    {
        #region Public Members

        #region DeleteItemByPrimaryKeyAsync

        public async System.Threading.Tasks.Task<int> DeleteItemByPrimaryKeyAsync(int serverConnectionId, long workItemTypeId)
        {
            global::Sidvall.Data.DeleteCriteria<global::Sidvall.WorkItemManager.Data.Fields.WorkItemTypeField> criteria;

            criteria = Sidvall.Data.CriteriaManager.NewDeleteCriteria<global::Sidvall.WorkItemManager.Data.Fields.WorkItemTypeField>();
            criteria.Filter = new global::Sidvall.Data.Filter<global::Sidvall.WorkItemManager.Data.Fields.WorkItemTypeField>();
            criteria.Filter.AddFilterItem(global::Sidvall.WorkItemManager.Data.Fields.WorkItemTypeField.WorkItemTypeId, Sidvall.Data.ComparisonOperator.Equal, workItemTypeId);
            ParameterManager.InitializeParameters(criteria, serverConnectionId);

            return await DeleteItemsAsync(criteria).ConfigureAwait(false);
        }

        #endregion
        #region GetItemByPrimaryKeyAsync

        public async System.Threading.Tasks.Task<TEntity> GetItemByPrimaryKeyAsync(int serverConnectionId, long workItemTypeId)
        {
            return await GetItemByPrimaryKeyAsync(serverConnectionId, workItemTypeId, null).ConfigureAwait(false);
        }
        public async System.Threading.Tasks.Task<TEntity> GetItemByPrimaryKeyAsync(int serverConnectionId, long workItemTypeId, System.Collections.Generic.IEnumerable<global::Sidvall.WorkItemManager.Data.Relations.WorkItemTypeRelation> includedEntities)
        {
            global::Sidvall.Data.FetchCriteria<global::Sidvall.WorkItemManager.Data.Fields.WorkItemTypeField, global::Sidvall.WorkItemManager.Data.Relations.WorkItemTypeRelation> criteria;

            criteria = Sidvall.Data.CriteriaManager.NewFetchCriteria<global::Sidvall.WorkItemManager.Data.Fields.WorkItemTypeField, global::Sidvall.WorkItemManager.Data.Relations.WorkItemTypeRelation>(null, null, includedEntities, null, null);
            criteria.Filter = new global::Sidvall.Data.Filter<global::Sidvall.WorkItemManager.Data.Fields.WorkItemTypeField>();
            criteria.Filter.AddFilterItem(global::Sidvall.WorkItemManager.Data.Fields.WorkItemTypeField.WorkItemTypeId, Sidvall.Data.ComparisonOperator.Equal, workItemTypeId);
            ParameterManager.InitializeParameters(criteria, serverConnectionId);

            return await GetItemAsync(criteria).ConfigureAwait(false);
        }

        #endregion

        #endregion
    }
}